date_create
DateTime::__construct alias - Returns a new DateTime object
The date_create()
function returns a new DateTime object.
Return a new DateTime object and format the date:
<?php $date = date_create ( "2016-09-25" ) ; echo date_format ( $date , "Y/m/d" ) ; ?>
Try it yourself
Returns a new DateTime object with the given time zone and formats the date and time:
<?php $date = date_create ( "2013-03-15 23:40:00" , timezone_open ( "Europe/Oslo" ) ) ; echo date_format ( $date , "Y/m/d H:iP" ) ; ?>
Try it yourself
date_create ( time , timezone ) ;
parameter | describe |
---|---|
time | Optional. Specify date/time string. NULL Indicates the current date/time. |
timezone |
Optional. Specifies the time zone. The default is the current time zone. Tip: View a list of all time zones supported in PHP . |